const Koa = require('koa');
const app = new Koa();

app.use(async(ctx) =>{
    let url = ctx.url;
    let request = ctx.request;

    /**
     *  query：返回的是格式化好的参数对象。
        querystring：返回的是请求字符串。
     */

    //从request中接收GET请求
    let req_query = request.query;
    let req_querystring = request.querystring;

    //不从request中接收GET,从上下文中获取GET请求
    let ctx_query = ctx.query;
    let ctx_querystring = ctx.querystring;    

    ctx.body = {
        url,
        req_query,
        req_querystring,
        ctx_query,
        ctx_querystring
    }
});

app.listen(3000,() => {
    console.log('[class3] server is starting at port 3000!');
});
